package view.Professeurs;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.Border;

import view.Param;

@SuppressWarnings("serial")
public class ExosButtonsPanel extends JPanel implements ActionListener {

	private JButton bAdd, bChange, bRemove;

	public ExosButtonsPanel() {

		// Alignement vertical des conteneurs
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

		// Creation des conteneurs
		bAdd = new JButton("Cr\u00E9er exercice");
		bChange = new JButton("Modifier exercice");
		bRemove = new JButton("Supprimer exercice");

		// Ajout de la transparence
		this.setOpaque(false);

		// Ajout des conteneurs
		this.add(bAdd);
		this.add(bChange);
		this.add(bRemove);

		// Ajout des marges
		this.setBorder(Param.wideMargin);
		Border margin = BorderFactory.createEmptyBorder(10, 5, 10, 5);		// top, left, bottom, right
		bAdd.setBorder(margin);
		bChange.setBorder(margin);
		bRemove.setBorder(margin);

		// Ajout des ecouteurs aux boutons
		bAdd.addActionListener(this);
		bChange.addActionListener(this);
		bRemove.addActionListener(this);

	}

	@Override
	public void actionPerformed(ActionEvent event) {

		if (event.getSource() == bAdd) {
			ProfPage.center.update(new ExosAddPanel());
		}
		else if (event.getSource() == bChange) {


		}
		else if (event.getSource() == bRemove) {

			ProfPage.center.update(new ExosDelPanel());

		}
	}

}
